import { _getUserInfo } from '@api/user'
import types from './types'
export default {
  async fetchUserInfo({ commit }) {
    let userId = sessionStorage.getItem("userId")
    if (userId == '' || userId == null) {
      let res ={}
      res.code=-400
      return res
    } else {
      let res = await _getUserInfo()
      if (res.code) {
        commit(types.SET_USER_ID, res.data.userId)
        commit(types.SET_USER_NAME, res.data.userName)
        commit(types.SET_USER_TYPE, res.data.userId)
      }
      return res
    }
  }
}
